//
//  ShenqingRZViewController.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/7/13.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "ShenqingRZViewController.h"

@interface ShenqingRZViewController ()<UIScrollViewDelegate>
//@property(nonatomic,strong)NSArray *titleArr;
//@property(nonatomic,strong)NSArray *picArr;

@end

@implementation ShenqingRZViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    titleLab.text = @"申请认证";
    titleLab.textColor = [UIColor whiteColor];
    [self setBackBar];
    titleLab.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = titleLab;
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    self.navigationController.navigationBar.barTintColor = COLOR_RGBA(77, 155, 255, 1);
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    self.tableView = tableView;
    
    self.tableView.rowHeight = 60;
    self.tableView.showsVerticalScrollIndicator = NO;
    

    
}
#pragma mark 导航栏左右Button
- (void)setBackBar{
    
    BackButton *backBtn=[BackButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 44, 44);
    [backBtn addTarget:self action:@selector(backController:) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [backBtn.imageView setContentMode:UIViewContentModeLeft];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
    [self.navigationItem setHidesBackButton:YES animated:YES];
    
}

- (void)backController:(UIButton *)button{
    self.navigationController.navigationBar.translucent = YES;
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor colorWithWhite:0.949 alpha:1.000];
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.numberOfLines = 0;
    titleLabel.font = [UIFont systemFontOfSize:14];
    [view addSubview:titleLabel];
    if (section == 0) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 50);
        titleLabel.text = @"这里是孵化项目的优秀平台,你可以找到资深的投资者,优秀的创业伙伴";
    }if (section == 1) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 50);
        titleLabel.text = @"在这里,您可以找到海量的投资项目,只要您有投资的想法,这就有无限可能,赶紧申请吧";
    }if (section == 2) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 50);
        titleLabel.text = @"在这里您可以选择优秀的创业伙伴一同创业,成为优秀项目的合作者也不是那么容易的.";
    }if (section == 3) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 60);
        titleLabel.text = @"如果你的经历比较丰富,如果你懂得创业之路,如果你有一点时间,快来这里认证一下,成为别人的导师.";
    }if (section == 4) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 60);
        titleLabel.text = @"如果你的经历比较丰富,如果你懂得创业之路,如果你有一点时间,快来这里认证一下,成为别人的导师.";
    }if (section == 5) {
        view.frame = CGRectMake(0, 0, kScreenWidth, 50);
        titleLabel.frame = CGRectMake(10, 0, kScreenWidth - 20, 60);
        titleLabel.text = @"如果你的经历比较丰富,如果你懂得创业之路,如果你有一点时间,快来这里认证一下,成为别人的导师.";
    }
    
    return view;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 0 || section == 1 || section == 2 ) {
        return 50;
    }else{
        return 60;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 6;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    // 定义cell标识  每个cell对应一个自己的标识
    NSString *CellIdentifier = [NSString stringWithFormat:@"cell%ld%ld",indexPath.section,indexPath.row];
    // 通过不同标识创建cell实例
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        UIImageView *pic = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 40, 40)];
        [cell.contentView addSubview:pic];
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 0, 150, 60)];
        [cell.contentView addSubview:titleLabel];
        
        if (indexPath.section == 0) {
            pic.image = [UIImage imageNamed:@"创业者"];
            titleLabel.text = @"创业者";
        }if (indexPath.section == 1) {
            pic.image = [UIImage imageNamed:@"投资人"];
            titleLabel.text = @"投资人";
        }if (indexPath.section == 2) {
            pic.image = [UIImage imageNamed:@"创业伙伴"];
            titleLabel.text = @"创业伙伴";
        }if (indexPath.section == 3) {
            pic.image = [UIImage imageNamed:@"创业导师"];
            titleLabel.text = @"创业导师";
        }if (indexPath.section == 4) {
            pic.image = [UIImage imageNamed:@"孵化"];
            titleLabel.text = @"共享孵化空间";
        }if (indexPath.section == 5) {
            pic.image = [UIImage imageNamed:@"信息服务"];
            titleLabel.text = @"信息服务提供者";
        }

        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        CreateProjectViewController *createVC = [[CreateProjectViewController alloc] init];
        [self.navigationController pushViewController:createVC animated:YES];
    }
    if (indexPath.section == 1) {
        ShenqingInvestorsController *shenqingInvestorsController = [[ShenqingInvestorsController alloc]init];
        [self.navigationController pushViewController:shenqingInvestorsController animated:YES];
        
    }
    if (indexPath.section == 2) {
        CreateTeacherViewController *createTeacherVC = [[CreateTeacherViewController alloc]init];
        [self.navigationController pushViewController:createTeacherVC animated:YES];
    }
    if (indexPath.section == 3) {
        CreateTeacherViewController *createTeacherVC = [[CreateTeacherViewController alloc]init];
        [self.navigationController pushViewController:createTeacherVC animated:YES];
    }
    if (indexPath.section == 4) {
        CreateShareIncubationSpaceController *createShareIncubationSpaceC = [[CreateShareIncubationSpaceController alloc]init];
        [self.navigationController pushViewController:createShareIncubationSpaceC animated:YES];
    }
    if (indexPath.section == 5) {
        MessageServiceProviderController *mspController = [[MessageServiceProviderController alloc]init];
        [self.navigationController pushViewController:mspController animated:YES];
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
    CGFloat sectionHeaderHeight = 60;//设置你footer高度
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.0001f;
}

//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
//{
//    
//    if (scrollView.contentOffset.y >= 0 && scrollView.contentOffset.y < 23){
//        NSLog(@"1  : %f",scrollView.contentOffset.y);
//        NSLog(@"1 : %f",scrollView.contentInset.top);
//        
//        scrollView.contentInset = UIEdgeInsetsMake(0, 0, -64, 0);
//        
//    } else if (scrollView.contentOffset.y == -64) {
//        
//        scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
//        NSLog(@"2  : %f",scrollView.contentOffset.y);
//        NSLog(@"2 : %f",scrollView.contentInset.top);
//    }
//    else if (scrollView.contentOffset.y < 0 &&scrollView.contentOffset.y != -64){
//        scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
//        NSLog(@"3 : %f",scrollView.contentOffset.y);
//    }
//    else if (scrollView.contentOffset.y >= 23 && scrollView.contentOffset.y <= 83){
//        scrollView.contentInset = UIEdgeInsetsMake(0, 0, -(83-scrollView.contentOffset.y), 0);
//        NSLog(@"4: %f",scrollView.contentOffset.y);
//        
//    }
//}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
